/**
 * 表单验证
 * 
 * @param {Object} rules 验证字段的规则
 * @param {Object} messages 验证字段的提示信息
 * 
 */

import basic from './basic.js';
var actmodel = new basic();
actmodel.do = "user_warehouse"
actmodel.offset = function (that, reset, para, xcsorts) { 
  if(!xcsorts)
  {
    xcsorts=[["id", "desc"], ["createtime", "desc"]] ;
  }
 
  var acturlpara = {};   
  acturlpara["url"] = "entry/wxapp/"+actmodel.do
  if (para) {
    para["op"] = "offset"
  }
  else {
    this.wherepara["op"] = "offset"
  }
  return actmodel.pagelist(acturlpara, that, reset, para, xcsorts);
}
actmodel.recordoffset = function (that, reset, para, xcsorts) { 
  if(!xcsorts)
  {
    xcsorts=[["id", "desc"], ["createtime", "desc"]] ;
  }
 
  var acturlpara = {};   
  acturlpara["url"] = "entry/wxapp/"+actmodel.do
  if (para) {
    para["op"] = "recordoffset"
  }
  else {
    this.wherepara["op"] = "recordoffset"
  }
  return actmodel.pagelist(acturlpara, that, reset, para, xcsorts);
}

//回收 或 托售 
actmodel.recovery = function (proid,model,type) {
  return new Promise((resolve) => {
    var urlpara = { do: actmodel.do, op: "recovery" };
    var postdata = { type,proid,model: JSON.stringify(model) }
    this.post(urlpara, postdata).then(res => {
      resolve(res)
    })
  })
}

//取消托售
actmodel.cancel = function (proid) {
  return new Promise((resolve) => {
    var urlpara = { do: actmodel.do, op: "cancel" };
    var postdata = { proid }
    this.post(urlpara, postdata).then(res => {
      resolve(res)
    })
  })
}

//托售列表
actmodel.salelist = function (proid) {
  return new Promise((resolve) => {
    var urlpara = { do: actmodel.do, op: "salelist" };
    var postdata = { proid }
    this.post(urlpara, postdata).then(res => {
      resolve(res)
    })
  })
}


//詢價列表
actmodel.mylist = function (proid) {
  return new Promise((resolve) => {
    var urlpara = { do: actmodel.do, op: "mylist" };
    var postdata = { proid }
    this.post(urlpara, postdata).then(res => {
      resolve(res)
    })
  })
}


//托售商品详情
actmodel.saleproinfo = function (proid,uid) {
  return new Promise((resolve) => {
    var urlpara = { do: actmodel.do, op: "saleproinfo" };
    var postdata = { proid,uid }
    this.post(urlpara, postdata,true).then(res => {
      resolve(res)
    })
  })
}

module.exports = actmodel;